"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
//10. 复习类相关知识
//本⼩节是复习类相关知识，如果有相关基础可以跳过。
var Person_Class = /** @class */ (function () {
    //构造器
    function Person_Class(name, age) {
        this.name = name;
        this.age = age;
    }
    //方法
    Person_Class.prototype.speack = function () {
        console.log("\u6211\u53EB\uFF1A".concat(this.name, ",\u4ECA\u5E74").concat(this.age, "\u5C81"));
    };
    return Person_Class;
}());
// const p1 = new Person_Class("张三", 18)
// console.log(p1)
// p1.speack()
//Student 继承 Person 
var Student = /** @class */ (function (_super) {
    __extends(Student, _super);
    //构造器
    function Student(name, age, grade) {
        //调用父类构造函数
        var _this = _super.call(this, name, age) || this;
        _this.grade = grade;
        return _this;
    }
    // ⼦类⾃⼰的⽅法
    Student.prototype.study = function () {
        console.log("".concat(this.name, "\u6B63\u5728\u52AA\u529B\u5B66\u4E60\u4E2D....."));
    };
    //覆盖父方法
    // speack() {
    //     console.log(`我叫：${this.name},今年${this.age}哈哈哈哈哈哈哈哈哈岁`)
    // }
    //重写父方法
    // 备注本例中若Student类不需要额外的属性，Student的构造器可以省略
    // 重写从⽗类继承的⽅法
    Student.prototype.speack = function () {
        console.log("\u6211\u53EB\uFF1A".concat(this.name, ",\u4ECA\u5E74").concat(this.age, "\u54C8\u54C8\u54C8\u54C8\u54C8\u54C8\u54C8\u54C8\u54C8\u5C81"));
    };
    return Student;
}(Person_Class));
var s1 = new Student('李同学', 16, '高三');
console.log(s1);
s1.study();
s1.speack();
//11. 属性修饰符
//   修饰符          含义                  具体规则
//   public         公开的           可以被：类内部、⼦类、类外部访问 。
//  protected      受保护的           可以被：类内部、⼦类访问。
//   private        私有的             可以被：类内部访问。
//   readonly      只读属性              属性⽆法修改。
//public 修饰符    类内部、⼦类、类外部访问
var Person_Class2 = /** @class */ (function () {
    //构造器
    function Person_Class2(name, age) {
        this.name = name;
        this.age = age;
    }
    //方法
    Person_Class2.prototype.speack = function () {
        console.log("\u6211\u53EB\uFF1A".concat(this.name, ",\u4ECA\u5E74").concat(this.age, "\u5C81"));
    };
    return Person_Class2;
}());
var Student2 = /** @class */ (function (_super) {
    __extends(Student2, _super);
    function Student2() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    // ⼦类⾃⼰的⽅法
    Student2.prototype.study = function () {
        console.log("".concat(this.name, "\u6B63\u5728\u52AA\u529B\u5B66\u4E60\u4E2D....."));
    };
    return Student2;
}(Person_Class2));
var stu2 = new Person_Class2("张三", 18);
stu2.name;
stu2.age;
stu2.speack();
//属性的简写形式
// =====> 简写前
var Person_Class3 = /** @class */ (function () {
    //构造器
    function Person_Class3(name, age) {
        this.name = name;
        this.age = age;
    }
    return Person_Class3;
}());
// =====> 简写后
var Person_Class4 = /** @class */ (function () {
    function Person_Class4(name, age) {
        this.name = name;
        this.age = age;
    }
    return Person_Class4;
}());
var st4 = new Person_Class4('麻子', 18);
// console.log(st4.age, st4.name)
//protected 修饰符    类内部、⼦类访问
var Person_Class5 = /** @class */ (function () {
    //简写形式
    function Person_Class5(name, age) {
        this.name = name;
        this.age = age;
    }
    //方法
    //getDetails是受保护⽅法，不能在类外部访问，但可以在【类】与【⼦类】中访问
    Person_Class5.prototype.getDetails = function () {
        return "\u6211\u53EB\uFF1A".concat(this.name, ",\u4ECA\u5E74").concat(this.age, "\u5C81");
    };
    Person_Class5.prototype.introduce = function () {
        console.log(this.getDetails());
    };
    return Person_Class5;
}());
//继承父类
var Student5 = /** @class */ (function (_super) {
    __extends(Student5, _super);
    function Student5(name, age, id) {
        var _this = _super.call(this, name, age) || this;
        _this.name = name;
        _this.age = age;
        _this.id = id;
        return _this;
    }
    // ⼦类⾃⼰的⽅法
    Student5.prototype.study = function () {
        console.log(this.getDetails(), "".concat(this.name, "\u6B63\u5728\u52AA\u529B\u5B66\u4E60\u4E2D....."));
    };
    return Student5;
}(Person_Class5));
var stu5 = new Person_Class5('麻子', 18);
// stu5.introduce()
// stu5.getDetails()
// stu5.name
// stu5.age
var per5 = new Student5('麻子', 18, 'xxxx');
per5.study();
//private 修饰符
var Person6 = /** @class */ (function () {
    //简写形式
    function Person6(name, age, 
    // IDCard属性为私有的(private)属性，只能在【类内部】使⽤
    IDCard) {
        this.name = name;
        this.age = age;
        this.IDCard = IDCard;
    }
    Person6.prototype.getPriviteInfo = function () {
        //// 类内部可以访问私有的(private)属性 —— IDCard
        return '身份证：' + this.IDCard;
    };
    Person6.prototype.getinfo = function () {
        return "\u6211\u53EB\uFF1A".concat(this.name, ",\u4ECA\u5E74").concat(this.age, "\u5C81");
    };
    Person6.prototype.getFullInfo = function () {
        return this.getinfo() + ',' + this.getPriviteInfo();
    };
    return Person6;
}());
var per6 = new Person6("tom", 18, '10000000000000000000000000');
per6.name;
per6.age;
// per6.IDCard
// console.log(per6.getFullInfo())
//readonly 修饰符
var Person7 = /** @class */ (function () {
    //简写形式
    function Person7(name, 
    //只读属性
    age) {
        this.name = name;
        this.age = age;
    }
    return Person7;
}());
var per7 = new Person7("tom", 18);
per7.name = "xxx";
// per7.age = 15
var Car = /** @class */ (function () {
    function Car(vin, //⻋辆识别码，为只读属性
    year, //出⼚年份，为只读属性
    color, sound) {
        this.vin = vin;
        this.year = year;
        this.color = color;
        this.sound = sound;
    }
    // 打印⻋辆信息
    Car.prototype.displayInfo = function () {
        console.log("\n    \u8BC6\u522B\u7801\uFF1A".concat(this.vin, ",\n    \u51FA\u2F1A\u5E74\u4EFD\uFF1A").concat(this.year, ",\n    \u989C\u2F8A\uFF1A").concat(this.color, ",\n    \u2FB3\u54CD\uFF1A").concat(this.sound, "\n    "));
    };
    return Car;
}());
var car = new Car('1HGCM82633A123456', 2018, '⿊⾊', 'Bose⾳响');
car.displayInfo();
// 以下代码均错误：不能修改 readonly 属性
// car.vin = '897WYE87HA8SGDD8SDGHF';
// car.year = 2020; 
